<?php
set_time_limit(0);
$root=preg_replace('/cron$/', '', dirname(__FILE__));

require_once($root."inc.config.php");

require_once($root."initialize.php");


if(($db_msg=cron_initialize()) !== true){
	print_r("Connection error");
}else{
	$r = mysql_query("SELECT * FROM gg_incentive WHERE counter>=0 AND uid>0");

    while($user = mysql_fetch_assoc($r))
	{
        $payout = @mysql_result(mysql_query("select sum(l+roi) from gg_member_comm_sum where uid=".$user["uid"]), 0);
        mysql_query("update gg_incentive set payout=".$payout." where id=".$user["id"]);
    }

    print_r('Done');
}
exit;		
?>